package com.jet.chat.message;

import com.jet.chat.exception.ChatException;

public class MessageQueueService implements Runnable {

	private MessageQueue messageQueue = new MessageQueue();
	private MessageWriter writer;

	public MessageQueueService(MessageWriter writer) {
		this.writer = writer;
	}

	public MessageQueue getMessageQueue() {
		return messageQueue;
	}

	@Override
	public void run() {
		while (true) {
			try {
				writer.write(this.messageQueue.getMessage());
			} catch (ChatException e) {
				e.printStackTrace();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
